﻿// IPC Library
// Interprocess Communication Library
// Copyright(C)2008 Bill Tudor
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IPCLibrary
{
	/// <summary>
	/// Read Complete event arguments.
	/// </summary>
	/// <seealso cref="IPCLibrary.Mailslot"/>
	public class ReadCompletedEventArgs : EventArgs
	{
		private byte[] _data;
		/// <summary>
		/// Data read.
		/// </summary>
		public byte[] Data
		{
			get { return _data; }
		}
		/// <summary>
		/// Construct a new event arguments instance.
		/// </summary>
		/// <param name="data">Data read.</param>
		public ReadCompletedEventArgs(byte[] data)
		{
			_data = data;
		}
		/// <summary>
		/// Convert the data to a string.
		/// </summary>
		/// <returns>String representation of the data.</returns>
		public override string ToString()
		{
			return Encoding.ASCII.GetString(_data);
		}
		/// <summary>
		/// Convert the data to a string.
		/// </summary>
		/// <param name="characterEncoding">Character encoding to use.</param>
		/// <returns>String representation of the data.</returns>
		public string ToString(Encoding characterEncoding)
		{
			return characterEncoding.GetString(_data);
		}
	}
}
